//
//  AppDelegate.m
//  timelyRain
//
//  Created by Jiafei Wei on 16/7/23.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//
#import "AppDelegate.h"
#import "ContactUtil.h"
#import "FileTool.h"
#define key @"anlang#timely"
@interface AppDelegate()


@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    EMOptions *options = [EMOptions optionsWithAppkey:key];//环信key
    options.apnsCertName = @"";//推送证书名
    [[EMClient sharedClient] initializeSDKWithOptions:options];
    
    //初始化环信UI
    [[EaseSDKHelper shareHelper] hyphenateApplication:application
                        didFinishLaunchingWithOptions:launchOptions
                                               appkey:key
                                         apnsCertName:@""
                                          otherConfig:@{kSDKConfigEnableConsoleLogger:[NSNumber numberWithBool:YES]}];
    
    [self initData];
    [ContactUtil share];//初始化联系人操作
    [FileTool writeGroupToContact];
    return YES;
}

-(void)initData{
    [self initRootCV];
}
-(void)initRootCV{
    _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    self.mbtApp = [MBTApp shareAppcation];
    self.navigationVC = [[UINavigationController alloc] initWithRootViewController:self.mbtApp.rooTVC];
    [self.mbtApp setAppcation];
    self.window.rootViewController =self.navigationVC;
}
// APP进入后台
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationDidEnterBackground:application];
}

// APP将要从后台返回
- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationWillEnterForeground:application];
}

@end
